Micron Document
Deavmi's coding shack

Node / mirrors / glog / commits / aba0d27

Commit aba0d278e7f72e146f2207ddcb4a794bb34752a0


Parents : 53e6ad7
Author : Tristan Brice Velloza Kildaire <deavmi@redxen.eu>
Date : 2026-05-01T14:33:19+02:00

simplified switch case

Changes

1 files changed, 8 insertions(+), 4 deletions(-)


Diff

diff --git a/std/appenders/structured/core.go b/std/appenders/structured/core.go
index f8f3788..97f2326 100644
--- a/std/appenders/structured/core.go
+++ b/std/appenders/structured/core.go
@@ -65,23 +65,27 @@ func (sa StructuredAppender) Do(lr record.LogRecord) error {
var newStuff map[string]any = map[string]any{}
for k, v := range m {
+ var stringedKey string
switch s := k.(type) {
// anything key that is a string
case string:
- newStuff[s] = sa.procValue(v)
+ stringedKey = s
// anything key that is an integer
case int:
- newStuff[fmt.Sprintf("%d", s)] = sa.procValue(v)
+ stringedKey = fmt.Sprintf("%d", s)
// anything key that is a bool
case bool:
- newStuff[fmt.Sprintf("%v", s)] = sa.procValue(v)
+ stringedKey = fmt.Sprintf("%v", s)
// anything key that can be stringed
case fmt.Stringer:
- newStuff[s.String()] = sa.procValue(v)
+ stringedKey = s.String()
// any other type of keys are unsupported
default:
return fmt.Errorf("Key '%v' of type %T is not supported as it cannot be converted to a string key", k, k)
}
+
+ // now store the value at the string-based key
+ newStuff[stringedKey] = sa.procValue(v)
}
encoder := json.NewEncoder(sa.w)

Served by rngit 1.5.0 - Generated in 0.05s